#include <iostream>

using namespace std;

typedef long long LL;

const int N = 10000 + 10;
LL f[N][N];
int q;

int main()
{
	cin >> q;
	int beginx = 0x3f3f3f3f, beginy = 0x3f3f3f3f, endx = 0, endy = 0;
	while(q--)
	{
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x1++; y1++; x2++; y2++;
		if(x1 > x2 && y1 > y2)
		{
			swap(x1, x2); swap(y1, y2);
		}
		if(x1 < x2 && y1 > y2)
		{
			swap(x1, x2);	
		}
		if(x2 < x1 && y2 > y1)
		{
			swap(y1, y2);
		}
		beginx = min(beginx, x1);
		beginy = min(beginy, y1);
		endx = max(endx, x2);
		endy = max(endy, y2);
		f[x1][y1]++;
		f[x2][y1]--;
		f[x1][y2]--;
		f[x2][y2]++;
	}
	
	for(int i = beginx; i <= endx + 10; i++) 
	{
		for(int j = beginy; j <= endy + 10; j++)
		{
			f[i][j] = f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1] + f[i][j];
		}
	}
	int ans = 0;
	for(int i = beginx; i <= endx + 10; i++) 
	{
		for(int j = beginy; j <= endy + 10; j++)
		{
			if(f[i][j]) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}
